package com.acme.bankapp.domain.accounting;

/**
 * Account without overdraft
 * 
 */
public class SavingAccount extends AbstractAccount {

	public SavingAccount(double balance) {
		super(balance);
	}

	public SavingAccount() {
		this(DEFAULT_INITIAL_BALANCE);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public double maximumAmountToWithdraw() {
		return balance;
	}

	@Override
	/** 
	 * {@inheritDoc}
	 */
	public void withdraw(double x) throws NotEnoughFundsException {
		if (balance >= x) {
			balance -= x;
		} else {
			throw new NotEnoughFundsException(x, balance);
		}
	}

}
